<template>
    <view class="content" v-if="isShow">
        <view class="nav">
            <view class="nav-i" :class="{active : type == 1}" @click="chooseNav(1)">待审核({{count.count1}})</view>
            <view class="nav-i" :class="{active : type == 2}" @click="chooseNav(2)">审核通过</view>
			<view class="nav-i" :class="{active : type == 3}" @click="chooseNav(3)">拒绝({{count.count3}})</view>
        </view>
        
        <view class="box" v-for="(item, index) in list" :key="index" @click="toDetails(item)">
            <view class="top">
                <view class="item u-flex-1">
                    <view class="left">订单编号</view>
                    <view class="right">{{item.out_trade_no}}</view>
                </view>
                <view class="o-sta1" v-if="item.order_type == 1">零担</view>
                <view class="o-sta2" v-if="item.order_type == 2">包车</view>
            </view>
            <view class="item">
                <view class="left">下单日期</view>
                <view class="right">{{item.create_time}}</view>
            </view>
            <view class="item">
                <view class="left">发货方</view>
                <view class="right">{{item.shipper}}</view>
            </view>
            <view class="item">
                <view class="left">联系人</view>
                <view class="right">{{item.shipper_contact}}</view>
            </view>
            <view class="item">
                <view class="left">联系方式</view>
                <view class="right">{{item.shipper_phone}}</view>
            </view>
            <view class="item">
                <view class="left">装车地点</view>
                <view class="right">{{item.loading_site}}</view>
            </view>
            <view class="item">
                <view class="left">收货地址</view>
                <view class="right">{{item.address}}</view>
            </view>
            
            <view class="item">
                <view class="left">经营位置</view>
                <view class="right">{{item.position}}</view>
            </view>
            <view class="item">
                <view class="left">联系人</view>
                <view class="right">{{item.recipient_contact}}</view>
            </view>
            <view class="item">
                <view class="left">联系方式</view>
                <view class="right">{{item.recipient_phone}}</view>
            </view>
            <view class="item">
                <view class="left">发车时间</view>
                <view class="right">{{item.start_time}}</view>
            </view>
            <view class="item" v-if="item.carriage">
                <view class="left">车厢位置</view>
                <view class="right">{{item.carriage}}</view>
            </view>
            <view class="item" v-if="item.remark">
                <view class="left">备注</view>
                <view class="right">{{item.remark}}</view>
            </view>
            <view class="item" v-if="item.cancel_reason">
                <view class="left">取消原因</view>
                <view class="right">{{item.cancel_reason}}</view>
            </view>
            <view class="item" v-if="item.reject_reason">
                <view class="left">拒绝原因</view>
                <view class="right">{{item.reject_reason}}</view>
            </view>
            <view class="item" v-if="item.examine_time">
                <view class="left">审核时间</view>
                <view class="right">{{item.examine_time}}</view>
            </view>
        </view>
		
		<view style="height: 94rpx;padding-top: 30rpx;">
		    <u-loadmore :status="status" v-if="status != 'loadmore'" />
		</view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                type: 1,
				isShow: false,
				status: 'loadmore', //是否显示没有更多了
				page: 1,
				list: [],
				count: {},
            };
        },
        onShow() {
        	this.list = []
        	this.page = 1
        	this.status = 'loadmore'
        	this.getList()
        },
        onReachBottom() {
        	if(this.page == 1){return}
        	this.getList()
        },
        methods: {
            toDetails(item) {
                this.$gTo(`/pages/cancel-order/details?id=${item.id}&type=${this.type}`)
            },
            
            chooseNav(num) {
            	if (this.type == num) return
                this.type = num
            	this.list = []
            	this.page = 1
            	this.status = 'loadmore'
            	this.getList()
            },
            
            getList() {
            	if (this.status == 'nomore') return;
            	this.status = 'loading';
            	this.$ajax('select_cancel_orders', {
            		user_token: this.$getSync('userToken'),
            		page: this.page,
            		limit: 10,
                    cancel_status: this.type,//1审核中 2通过 3驳回
            	}).then(ret => {
            		if (ret.success == 1000) {
            			this.count = ret.detail
            			
            			if (ret.detail && ret.detail.orders && ret.detail.orders.length > 0) {
            				this.list = this.list.concat(ret.detail.orders);
            				this.page++;
            				this.status = 'loadmore'
            			} else {
            				this.status = 'nomore'
            			}
            			this.isShow = true
            		} else {
            			this.$toast(ret.msg);
            		}
            	});
            },
        }
    };
</script>

<style lang="scss">
    
    
    page{
        background-color: #eef1f6;
    }
    .content{
        padding-bottom: 50rpx;
    }
    .nav{
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 30rpx 0;
        border-bottom: 2rpx solid #ebebeb;
        background-color: #fff;
    }
    .nav-i{
        width: calc(100vw / 3);
        font-size: 28rpx;
        text-align: center;
        position: relative;
    }
    .active{
        color: #004580;
        font-weight: bold;
        position: relative;
    }
    .active::after{
        display: block;
        content: '';
        width: 32rpx;
        height: 8rpx;
        background-color: #004580;
        position: absolute;
        bottom: -30rpx;
        left: 50%;
        transform: translateX(-50%);
    }
    
    .box{
        background-color: #fff;
        border-radius: 15rpx;
        padding: 40rpx 30rpx 30rpx;
        margin: 16rpx 20rpx 0;
    }
    .top{
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .item{
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-bottom: 10rpx;
    }
    .left{
        width: 140rpx;
        color: #656565;
    }
    .right{
        flex: 1;
        word-break: break-all;
        white-space: pre-line;
    }
    .o-sta{
        font-size: 24rpx;
        color: #ff602c;
        padding-bottom: 10rpx;
        padding-left: 10rpx;
    }
    .o-sta1{
        font-size: 24rpx;
        color: #ff602c;
        padding: 7rpx 15rpx;
        background-color: #fff1ec;
        border-radius: 10rpx;
        margin-left: 10rpx;
        margin-bottom: 10rpx;
    }
    .o-sta2{
        font-size: 24rpx;
        color: #0075ff;
        padding: 7rpx 15rpx;
        background-color: #ebf4fe;
        border-radius: 10rpx;
        margin-left: 10rpx;
        margin-bottom: 10rpx;
    }
    
    

</style>
